/*
    This file is part of Raptor.

    Raptor is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Raptor is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Raptor.  If not, see <http://www.gnu.org/licenses/>.

 */

#ifndef CAPTCHADIALOG_H
#define CAPTCHADIALOG_H

#include <QDialog>
#include <QtGui>
#include <QUrl>
#include <QHttp>
#include <QHttpRequestHeader>

class captchaDialog : public QDialog
{
    Q_OBJECT

    public:
        captchaDialog(QString const& captcha, QString const& captchaDir, QString const& prefix, QString const& filetype);
        ~captchaDialog();

        QString captcha() const
        {
            if(lineEditCaptcha)
                return lineEditCaptcha->text();
            else
                return "";
        };

    public slots:

    private:
        QPointer<QHttp> http;

        QPointer<QGridLayout> layout;
        QPointer<QLabel> topLabel;
        QPointer<QLineEdit> lineEditCaptcha;
        QPointer<QLabel> captchaLabel;
        QPointer<QPushButton> okButton;
        QPointer<QTemporaryFile> captchaFile;

        int waitingId;
        QString errorString;
        bool abort;

    private slots:
        void slot_http_sslErrors(const QList<QSslError> & errors);
        void slot_http_requestFinished(int id, bool error);
};

#endif // CAPTCHADIALOG_H
